package ExerciseClass.Exercise33;

import java.io.*;

public class Exercise2 {
    public static void main(String[] args) {
        long stat = System.currentTimeMillis();
        BufferedInputStream src= null;
        BufferedOutputStream dest= null;
        try {
            src = new BufferedInputStream(new FileInputStream(new File("F:\\123.txt")));
            dest = new BufferedOutputStream(new FileOutputStream(new File("F:\\1234.txt")));

            byte arr [ ] = new byte[1024];
            int len;
            while((len = src.read(arr))!=-1){
                //正常输出
                dest.write(arr,0,len);
                //以下加密
//            for(int i =0;i<len;i++){
//                arr[i] = (byte)(arr[i] ^ 5 );
//            }
//            dest.write(arr,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(src!=null){
                try {
                    src.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(dest!=null){
                try {
                    dest.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
       long end = System.currentTimeMillis();
        System.out.println("运行的时间为：" +(end - stat));
    }
}
